Skip to content

Support optional result indication when accepting an approval request#1396

Merged
matthewwalsh0 merged 4 commits into
mainfrom
chore/approval-controller-accept-result
May 30, 2023
Merged

Support optional result indication when accepting an approval request#1396
matthewwalsh0 merged 4 commits into
mainfrom
chore/approval-controller-accept-result

Conversation

@matthewwalsh0
Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 commented May 26, 2023

Description

Update the accept method of the ApprovalController to return a promise which optionally only resolves once the approval request creator has indicated the success or failure of any post-approval logic.

This is achieved using callbacks optionally provided in the approval request promise.

This is necessary to support more complex approval flows in which the request acceptor, typically a client frontend, must know the success of the resulting logic, or must receive some resulting data.

Changes

  • ADDED: waitForResult option to accept method to resolve new promise when success or failure is indicated.
  • ADDED: expectsResult option to add and addAndShowApprovalRequest method to change the resolved promise to return a result object including the value and new resultCallbacks.
  • ADDED: expectsResult property to ApprovalRequest to store return type preference in state.
  • ADDED: Associated types including AddResult, AcceptResult, AcceptResultCallbacks, and AcceptOptions.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation for new or updated code as appropriate (note: this will usually be JSDoc)
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review May 26, 2023 14:05
@matthewwalsh0 matthewwalsh0 requested a review from a team as a code owner May 26, 2023 14:05
Comment thread packages/approval-controller/src/ApprovalController.ts
Comment thread packages/approval-controller/src/ApprovalController.ts Outdated
@matthewwalsh0 matthewwalsh0 merged commit 7191870 into main May 30, 2023
@matthewwalsh0 matthewwalsh0 deleted the chore/approval-controller-accept-result branch May 30, 2023 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants